﻿@using CoralNode.Core.Entity.Domains.Site
@model CoralNode.Core.Entity.Domains.Site.ThemeDomain

<div id="pbody" class="pbody_style2">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_setting_setting"></span><span class="t t_c">快速设置</span>
        </div>
        <form id="spform" action="/m/quickSetting/SettingTheme" method="post" enctype="multipart/form-data">
            <div id="main">
                <div class="step">
                    <ul>
                        <li><span class="ico ico_step_over"></span><span class="t">基本信息</span>
                        </li>
                        <li><i></i></li>
                        <li><span class="ico ico_step_over"></span><span class="t">扩展信息</span></li>
                        <li><i></i></li>
                        <li><span class="ico ico_step_over"></span><span class="t">内容结构</span></li>
                        <li><i></i></li>
                        <li><span class="ico ico_step_over"></span><span class="t">菜单结构</span></li>
                        <li><i></i></li>
                        <li><span class="ico ico_step_current"></span><span class="t">网站外观</span></li>
                        <li><i></i></li>
                        <li><span class="ico ico_step_noover"></span><span class="t">权限设置</span></li>
                        <li><i></i></li>
                        <li><span class="ico ico_step_noover"></span><span class="t">性能设置</span></li>
                        <li><i></i></li>
                        <li><span class="ico ico_step_noover"></span><span class="t">完成</span></li>
                    </ul>
                </div>
                <div class="table_form form_main step_content">
                    <div class="box clearfix js_addbox">
                        <div class="c_prototype">新增主题</div>
                        <div class="theme clearfix" style="background-color: #ffffff">
                            <img class="l mr_2" src="/Themes/CoralAdmin/_misc/images/defaultTheme.jpg" />
                            <div class="l w_36">
                                @Html.HiddenFor(n => n.Id)
                                @Html.TextBoxFor(m => m.Name, new { @class = "text w_36 mb_2 js-watermark required", @msg = "主题名称" })
                                @Html.TextBoxFor(m => m.Code, new { @class = "text w_36 mb_2 js-watermark required", @msg = "主题代码" })
                                @Html.TextAreaFor(m => m.Description, new { @class = "w_36 h_9-5 mb_2 js-watermark", @msg = "主题描述" })
                                <input type="hidden" name="Thumb" />
                                <ul class="list_pic" href="/m/common/upload">
                                    <li module="theme/thumb" class="add">添加</li>
                                </ul>
                            </div>
                        </div>
                        <div class="b_footer clearfix">
                            <input type="submit" class="btn_2" style="float: right" value="添加">
                        </div>
                    </div>
                    @foreach (var item in ViewBag.ThemeList) {
                        <div class="box clearfix">
                            @if (ViewBag.Site.ThemeCode != @item.Code) {
                                <div class="c_prototype" style="background-color: #eff2f5" data-code="@item.Code">@item.Name
                                </div>
                            } else {
                                <div class="c_prototype" style="background-color: #e7f2d9">@item.Name</div>
                            }
                            <div class="theme clearfix" style="background-color: #ffffff">
                                @if (string.IsNullOrEmpty(item.Thumb)) {
                                    <img class="l mr_2" src="/Themes/CoralAdmin/_misc/images/defaultTheme.jpg" />
                                } else {
                                    <img class="l mr_2" src="@item.Thumb" />
                                }
                                <textarea class="w_36 h_9-5" disabled="disabled">@item.Description</textarea>
                            </div>
                            <div class="b_footer clearfix">
                                <div class="r">
                                    <a href="@item.Id" class="js-chooseTheme">使用该主题</a>
                                </div>
                            </div>
                        </div>
                    }
                </div>
                <div class="ml_39 p_2">
                    <a class="btn_1 mr_2 enable" href="/m/quickSetting/SettingMenu">上一步</a><input
                        type="submit" class="btn_1" value="下一步" />
                </div>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $('.js-chooseTheme').live("click", function (e) {
            e.preventDefault();
            $("form").find("input[name='Id']").val($(this).attr("href"));
            $(".js_addbox").hide();
            $("form").submit();
        });
        $("form").submit(function (e) {
            var $this = $(this);
            var code = $this.find("input[name='Code']").val();
            var flag = true;
            $(".c_prototype[data-code]").each(function () {
                if ($(this).attr("data-code") == code)
                    flag = false;
            });
            if (!flag) {
                $.alert("已存在该主题代码，请重新输入！");
                $this.find("input[name='Code']").focus();
                return false;
            }
            $(".js_addbox").hide();
        });
    })

</script>
